#include "WinMutex.h"

WinMutex::WinMutex(void)
{
	if ((m_ghMutex = CreateMutex(NULL, FALSE, NULL)) == NULL)
		throw ServerException("Can't create mutex");
}


WinMutex::~WinMutex(void)
{
	DWORD lpdwFlags[100];
	if (GetHandleInformation(m_ghMutex, lpdwFlags)!= 0)
		CloseHandle(m_ghMutex);
}

void WinMutex::lock()
{
	WaitForSingleObject(m_ghMutex, INFINITE);
}

void WinMutex::unlock()
{
	ReleaseMutex(m_ghMutex);
}